package com.example.interview.example.mobileBilling;

public class ComputeStrategy {
    private int customerType;
    private int packType;
    private int businessType;
    private String businessName = "";

    public ComputeStrategy(int customerType, int packType, int businessType) {
        this.customerType = customerType;
        this.packType = packType;
        this.businessType = businessType;
        switch(businessType){
            case 0:businessName = "电话";break;
            case 1:businessName = "短信";break;
            case 2:businessName = "数据";break;
        }
    }

    public int computeMoney(int quantity){
        int price = ConfigManager.getPrice(customerType, packType,businessType);

        int freeQuantity = ConfigManager.getFree(customerType, packType,businessType);
        int chargeQuantity = quantity - freeQuantity;
        if(chargeQuantity < 0){
            chargeQuantity = 0;
        }
        int phoneBaseMoney = ConfigManager.getRent(customerType, packType,businessType);
        System.out.print(businessName + "功能费：" + phoneBaseMoney + "厘钱,");
        int fee = price * chargeQuantity;
        System.out.println(businessName + "计价费：" + quantity + "-" + freeQuantity + "=" + chargeQuantity + ","
                + chargeQuantity + "*" + price + "=" + fee +"厘钱");
        return phoneBaseMoney + fee;
    }
}
